<template>
	<view class="repair-wrap">
		<view class="tab_nav" style="background-color: #FFFFFF;">
			<view class="navTitle" v-for="(item,index) in navList" :key="index">
				<view :class="{'active':isActive === item.index}" @click="checked(item.index)">
					{{item.title}}
				</view>
			</view>
		</view>

		<view class="">
			<view class="search">
				<input class="search-input" v-model="result" placeholder='请输入关键字' />
				<view class="btn" @click="searchName">
					<text style="color: #FFFFFF;">搜索</text>
				</view>
			</view>
		</view>

		<view class="list-view" v-if="isActive==0">
			<view class="bor_None" v-if="wprkList.length == 0">
				<view class="bor_Noneone">
					<image class="bor_Noneimage" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/2023-04-07_image/9015d0e9f45344c4007d408cd271f6a.png" mode="">
					</image>
				</view>
				<view class="bor_Nonetext">暂无数据</view>
			</view>
			<view class="list-ul" v-for="(item, index) in wprkList" :key="index"
				@click="navTo('/homePage/technological/workprocessDetail',item)">
				<image style="width: 20px;height: 16px;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/file/2023-03-09/2411d0d3544e3932cdbf66234eccdbb.png" mode=""></image>
				<view class="list-title" style="margin-left: 10px;">
					<h3>{{item.workflow_name}}</h3>
				</view>
				<image src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/right.png" style="width: 9px;height: 14px;" mode=""></image>
			</view>
		</view>
		<view class="list-view" v-if="isActive==1">
			<view class="bor_None" v-if="systemData.length == 0">
				<view class="bor_Noneone">
					<image class="bor_Noneimage" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/2023-04-07_image/9015d0e9f45344c4007d408cd271f6a.png" mode="">
					</image>
				</view>
				<view class="bor_Nonetext">暂无数据</view>
			</view>
			<view class="list-ul" v-for="(item, index) in systemData" :key="index"
				@click="navTo('/homePage/technological/systemDetail',item)">
				<image style="width: 20px;height: 16px;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/file/2023-03-09/b2b09fb1523767089a74779c2951669.png" mode=""></image>

				<view class="list-title" style="margin-left: 3px;margin-top: 10px;">
					<h3>{{item.regulations_name}}</h3>
				</view>
				<image src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/right.png" style="width: 9px;height: 14px;" mode=""></image>
			</view>
		</view>

		<view class="list-view" v-if="isActive==2">
			<view class="bor_None" v-if="postData.length == 0">
				<view class="bor_Noneone">
					<image class="bor_Noneimage" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/2023-04-07_image/9015d0e9f45344c4007d408cd271f6a.png" mode="">
					</image>
				</view>
				<view class="bor_Nonetext">暂无数据</view>
			</view>
			<view class="list-ul" v-for="(item, index) in postData" :key="index" @click="handlePost(item.post_id)">
				<image style="width: 20px;height: 16px;margin-top: 1px;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/postList.png" mode=""></image>
				<view class="list-title" style="margin-left: 10px;margin-top: 1px;">
					<h3>{{(item.pro_name + '-' + item.dept_name + '-' + item.post_name + '职责').length > 17 ?
						(item.pro_name + '-' + item.dept_name + '-' + item.post_name + '职责').slice(0, 17) + '...' : 
						(item.pro_name + '-' + item.dept_name + '-' + item.post_name + '职责')}}
					</h3>
				</view>
				<image src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/right.png" style="width: 9px;height: 14px;" mode=""></image>
			</view>
		</view>

		<!-- 提交弹窗 -->
		<view class="modal" v-if="submission">
			<view class="modal-cont">
				<view class="modal-title" style="margin-top: 18px;">
					岗位职责详情
				</view>

				<view style="padding: 10px 20px;margin-top: 7px;">
					<view>
						<image style="width: 34px;height: 28px;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/file/2023-03-09/ebf92839f2c72a7fb56c8bf408f47f4.png" mode=""></image>

					</view>
					<view style="text-align: center;margin-top: -26px;">
						{{postDutyData.dept_name}}-{{postDutyData.post_name}}职责
					</view>
				</view>
				<view style="padding: 10px 20px;height: 319px;margin-top: 10px;">
					<view style="letter-spacing: 1.5px;height: 290px;overflow: auto;">
						<span style="margin-left: 10px;margin-left: 34px;">{{postDutyData.post_duty}}</span>

					</view>
				</view>

				<view class="modal-bottom">
					<view class="btn-cancel1" @click="submission = false">关闭</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

				isActive: 2,
				inday: 0,
				navList: [{
						index: 2,
						title: "岗位职责"
					},
					{
						index: 1,
						title: "规章制度"
					},
					{
						index: 0,
						title: '工作流程'
					}
				],
				processList: [{}, {}, {}],
				wprkList: [],
				pageIndex: 1,
				systemData: [],
				postDutyData: {},
				submission: false,
				postData: [],
				result: ''
			}
		},
		onShow() {
			this.checkeds();
		},
		onPullDownRefresh() {
			this.getPostList()
		},
		methods: {
			checkeds() {
				let _this = this
				if (uni.getStorageSync('phone')) {
					if (uni.getStorageSync('loginFlag')) {
						if (!uni.getStorageSync('hourseList')) {
							uni.showModal({
								title: '请先进行业主认证',
								showCancel: false,
								confirmText: '确认',
								confirmColor: '#F9A832',
								success: function(res) {
									if (res.confirm) {
										_this.$Router.push({
											path: '/my/address/address'
										})
									}
								}
							});
							this.$openInvite()
						} else {
							_this.showFlag = true
							_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
							_this.name = _this.homelist.proName;
							_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' +
								_this.homelist.roomUnitNumber + '-' + _this.homelist.roomCode
							this.getPostList()
						}
					} else {
						uni.showModal({
							title: '请先实名认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/homePage1/realName/realName'
									})
								}
							}
						});
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								console.log('a')
								_this.$Router.pushTab({
									path: '/pages/user/user'
								})
							}
						}
					});
				}
			},
			handlePost(id) {
				this.$request.api.getPost({
					post_id: id
				}).then(res => {
					this.postDutyData = res.data.data
					this.submission = true
				})
			},
			// 获取列表
			getList() {
				uni.showLoading({
					title: "加载中"
				})
				this.$request.api.getWrokFlow({
					pageIndex: this.pageIndex,
					pagesize: 10,
					project_id: uni.getStorageSync('projectItem').proId,
					workflow_name: this.result,
					open_workflow: 2,
				}).then(res => {
					this.wprkList = res.data.data.datalist
					console.log(this.wprkList)
					uni.hideLoading();
					uni.stopPullDownRefresh()
				})
			},
			getsystemList() {
				this.$request.api.getsystem({
					pageIndex: this.pageIndex,
					project_id: uni.getStorageSync('projectItem').proId,
					regulations_name: this.result,
					states: 0, //有效、无效
					open_rules: 2,
				}).then(res => {
					this.systemData = res.data.data.datalist
					console.log(this.systemData)
				})
			},
			getPostList() {
				uni.showLoading({
					title: "加载中"
				})
				this.$request.api.getPostList({
					project_id: uni.getStorageSync('projectItem').proId,
					pageIndex: this.pageIndex,
					post_name: this.result
				}).then(res => {
					this.postData = res.data.data.datalist
					console.log(this.postData)
					uni.hideLoading();
					uni.stopPullDownRefresh()
				})
			},
			checked(index) {
				this.result = null;
				this.isActive = index
				if (index == 0) {
					this.getList()
				}
				if (index == 1) {
					this.getsystemList()
				}
				if (index == 2) {
					this.getPostList()
				}
			},
			searchName() {
				console.log('点击搜索++' + this.isActive)
				if (this.isActive == 0) {
					this.getList()
				}
				if (this.isActive == 1) {
					this.getsystemList()
				}
				if (this.isActive == 2) {
					this.getPostList()
				}
			},
			navTo(url, item) {
				let items = encodeURIComponent(JSON.stringify(item))
				uni.navigateTo({
					url: url + '?item=' + items
				})
			},
		}
	}
</script>


<style lang="scss">
	.repair-wrap {
		width: 100%;
		min-height: 100vh;
		height: auto;
		background: #f4f4f4;
		overflow: hidden;

		.repair-box {
			background: #fff;

			.repair-titel {
				height: 44rpx;
				line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}

	.tab_nav {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.tab_nav .navTitle {
		height: 90rpx;
		line-height: 90rpx;
		width: 100%;
		text-align: center;
		font-size: 32rpx;
		font-family: Alibaba PuHuiTi;
		color: #333;
	}

	.active {
		position: relative;
		color: #427705;
	}

	.active::after {
		content: "";
		position: absolute;
		width: 100rpx;
		height: 4rpx;
		background-color: #427705;
		left: 0px;
		right: 0px;
		bottom: 10px;
		margin: auto;
	}

	.list-view {
		margin-top: 20rpx;
		.list-ul {
			padding: 44rpx 36rpx;
			display: flex;
			align-items: center;
			background: #ffffff;
			border-bottom: 1rpx solid #EEEEEE;

			.list-icon {
				width: 80rpx;
				height: 80rpx;
				background: #427705;
				text-align: center;
				line-height: 80rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #ffffff;
				border-radius: 12rpx;
				margin-right: 30rpx;
			}
			.list-title {
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 45rpx;
				height: 45rpx;
				width: 560rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
	}

	.list-ul i {
		width: 6px;
		height: 13px;
		background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		border-radius: 4px;
		display: inline-block;
		vertical-align: middle;
	}

	.bor_None {
		.bor_Noneone {
			width: 232px;
			height: 242px;
			margin: 110px auto;
			.bor_Noneimage {
				width: 100%;
				height: 100%;
			}
		}
		.bor_Nonetext {
			width: 62%;
			margin: -66px auto;
			text-align: center;
			color: #999;
		}
	}
	.modal {
		position: fixed;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.8);
		z-index: 10;
	}
	.modal-cont {
		width: 610rpx;
		background: #ffffff;
		box-shadow: 0rpx 6rpx 12rpx 0rpx rgba(0, 0, 0, 0.12);
		border-radius: 24rpx;
		display: flex;
		flex-direction: column;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
	.modal-icon {
		width: 80rpx;
		height: 80rpx;
		margin-top: 67rpx;
	}
	.modal-title {
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: #333333;
		line-height: 45rpx;
		margin-top: 22rpx;
		align-items: center;
		border-bottom: 1px solid #ddd;
		padding: 0px 20px 10px;
		text-align: center;
		width: 89%;
		margin: auto;
	}
	.modal-bottom {
		width: 89%;
		height: 84rpx;
		border-top: 1rpx solid #e6e9ed;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 50rpx;
		margin: auto;
	}

	.btn-cancel1 {
		width: 100%;
		height: 84rpx;
		text-align: center;
		line-height: 84rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		box-sizing: border-box;
	}
	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #3d7fff;
		height: 100rpx;
		border-bottom: 1rpx solid #eeeeee;
		width: 100%;
		padding-left: 27px;
		padding-right: 31px;
		z-index: 20;
		background: #FFFFFF;

		.search-clear {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			left: 271px;
			top: 50%;
			transform: translateY(-50%);
		}
	
		.search-input {
			width: 312px;
			height: 66rpx;
			background: #f0f2f5;
			border-radius: 33rpx;
			line-height: 66rpx;
			font-size: 13px;
			padding: 0 33rpx;
			color: #333333;
			box-sizing: border-box;
		}
		.btn {
			width: 21%;
			line-height: 33px;
			border: 1px solid linear-gradient(180deg, #76D904 0%, #417505 100%);
			border-radius: 18px;
			text-align: center;
			margin-left: -43px;
			background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		}
	}
</style>